
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;

using MyGeneration.dOOdads;

namespace Camelio.DAL
{
	public abstract class _Sales : SqlClientEntity
	{
		public _Sales()
		{
			this.QuerySource = "Sales";
			this.MappingName = "Sales";

		}	

		//=================================================================
		//  public Overrides void AddNew()
		//=================================================================
		//
		//=================================================================
		public override void AddNew()
		{
			base.AddNew();
			
		}
		
		
		public override void FlushData()
		{
			this._whereClause = null;
			this._aggregateClause = null;
			base.FlushData();
		}
		
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_SalesLoadAll]", parameters);
		}
	
		//=================================================================
		// public Overridable Function LoadByPrimaryKey()  As Boolean
		//=================================================================
		//  Loads a single row of via the primary key
		//=================================================================
		public virtual bool LoadByPrimaryKey(int SaleID)
		{
			ListDictionary parameters = new ListDictionary();
			parameters.Add(Parameters.SaleID, SaleID);

		
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_SalesLoadByPrimaryKey]", parameters);
		}
		
		#region Parameters
		protected class Parameters
		{
			
			public static SqlParameter SaleID
			{
				get
				{
					return new SqlParameter("@SaleID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter ProdID
			{
				get
				{
					return new SqlParameter("@ProdID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter SaledPrice
			{
				get
				{
					return new SqlParameter("@SaledPrice", SqlDbType.Float, 0);
				}
			}
			
			public static SqlParameter SaleDate
			{
				get
				{
					return new SqlParameter("@SaleDate", SqlDbType.NVarChar, 50);
				}
			}
			
			public static SqlParameter SaleTime
			{
				get
				{
					return new SqlParameter("@SaleTime", SqlDbType.NVarChar, 50);
				}
			}
			
			public static SqlParameter SaleQuantity
			{
				get
				{
					return new SqlParameter("@SaleQuantity", SqlDbType.Int, 0);
				}
			}
			
		}
		#endregion		
	
		#region ColumnNames
		public class ColumnNames
		{  
            public const string SaleID = "SaleID";
            public const string ProdID = "ProdID";
            public const string SaledPrice = "SaledPrice";
            public const string SaleDate = "SaleDate";
            public const string SaleTime = "SaleTime";
            public const string SaleQuantity = "SaleQuantity";

			static public string ToPropertyName(string columnName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[SaleID] = _Sales.PropertyNames.SaleID;
					ht[ProdID] = _Sales.PropertyNames.ProdID;
					ht[SaledPrice] = _Sales.PropertyNames.SaledPrice;
					ht[SaleDate] = _Sales.PropertyNames.SaleDate;
					ht[SaleTime] = _Sales.PropertyNames.SaleTime;
					ht[SaleQuantity] = _Sales.PropertyNames.SaleQuantity;

				}
				return (string)ht[columnName];
			}

			static private Hashtable ht = null;			 
		}
		#endregion
		
		#region PropertyNames
		public class PropertyNames
		{  
            public const string SaleID = "SaleID";
            public const string ProdID = "ProdID";
            public const string SaledPrice = "SaledPrice";
            public const string SaleDate = "SaleDate";
            public const string SaleTime = "SaleTime";
            public const string SaleQuantity = "SaleQuantity";

			static public string ToColumnName(string propertyName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[SaleID] = _Sales.ColumnNames.SaleID;
					ht[ProdID] = _Sales.ColumnNames.ProdID;
					ht[SaledPrice] = _Sales.ColumnNames.SaledPrice;
					ht[SaleDate] = _Sales.ColumnNames.SaleDate;
					ht[SaleTime] = _Sales.ColumnNames.SaleTime;
					ht[SaleQuantity] = _Sales.ColumnNames.SaleQuantity;

				}
				return (string)ht[propertyName];
			}

			static private Hashtable ht = null;			 
		}			 
		#endregion	

		#region StringPropertyNames
		public class StringPropertyNames
		{  
            public const string SaleID = "s_SaleID";
            public const string ProdID = "s_ProdID";
            public const string SaledPrice = "s_SaledPrice";
            public const string SaleDate = "s_SaleDate";
            public const string SaleTime = "s_SaleTime";
            public const string SaleQuantity = "s_SaleQuantity";

		}
		#endregion		
		
		#region Properties
	
		public virtual int SaleID
	    {
			get
	        {
				return base.Getint(ColumnNames.SaleID);
			}
			set
	        {
				base.Setint(ColumnNames.SaleID, value);
			}
		}

		public virtual int ProdID
	    {
			get
	        {
				return base.Getint(ColumnNames.ProdID);
			}
			set
	        {
				base.Setint(ColumnNames.ProdID, value);
			}
		}

		public virtual double SaledPrice
	    {
			get
	        {
				return base.Getdouble(ColumnNames.SaledPrice);
			}
			set
	        {
				base.Setdouble(ColumnNames.SaledPrice, value);
			}
		}

		public virtual string SaleDate
	    {
			get
	        {
				return base.Getstring(ColumnNames.SaleDate);
			}
			set
	        {
				base.Setstring(ColumnNames.SaleDate, value);
			}
		}

		public virtual string SaleTime
	    {
			get
	        {
				return base.Getstring(ColumnNames.SaleTime);
			}
			set
	        {
				base.Setstring(ColumnNames.SaleTime, value);
			}
		}

		public virtual int SaleQuantity
	    {
			get
	        {
				return base.Getint(ColumnNames.SaleQuantity);
			}
			set
	        {
				base.Setint(ColumnNames.SaleQuantity, value);
			}
		}


		#endregion
		
		#region String Properties
	
		public virtual string s_SaleID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SaleID) ? string.Empty : base.GetintAsString(ColumnNames.SaleID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SaleID);
				else
					this.SaleID = base.SetintAsString(ColumnNames.SaleID, value);
			}
		}

		public virtual string s_ProdID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.ProdID) ? string.Empty : base.GetintAsString(ColumnNames.ProdID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.ProdID);
				else
					this.ProdID = base.SetintAsString(ColumnNames.ProdID, value);
			}
		}

		public virtual string s_SaledPrice
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SaledPrice) ? string.Empty : base.GetdoubleAsString(ColumnNames.SaledPrice);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SaledPrice);
				else
					this.SaledPrice = base.SetdoubleAsString(ColumnNames.SaledPrice, value);
			}
		}

		public virtual string s_SaleDate
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SaleDate) ? string.Empty : base.GetstringAsString(ColumnNames.SaleDate);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SaleDate);
				else
					this.SaleDate = base.SetstringAsString(ColumnNames.SaleDate, value);
			}
		}

		public virtual string s_SaleTime
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SaleTime) ? string.Empty : base.GetstringAsString(ColumnNames.SaleTime);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SaleTime);
				else
					this.SaleTime = base.SetstringAsString(ColumnNames.SaleTime, value);
			}
		}

		public virtual string s_SaleQuantity
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SaleQuantity) ? string.Empty : base.GetintAsString(ColumnNames.SaleQuantity);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SaleQuantity);
				else
					this.SaleQuantity = base.SetintAsString(ColumnNames.SaleQuantity, value);
			}
		}


		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region WhereParameter TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter SaleID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SaleID, Parameters.SaleID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter ProdID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.ProdID, Parameters.ProdID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SaledPrice
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SaledPrice, Parameters.SaledPrice);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SaleDate
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SaleDate, Parameters.SaleDate);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SaleTime
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SaleTime, Parameters.SaleTime);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SaleQuantity
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SaleQuantity, Parameters.SaleQuantity);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter SaleID
		    {
				get
		        {
					if(_SaleID_W == null)
	        	    {
						_SaleID_W = TearOff.SaleID;
					}
					return _SaleID_W;
				}
			}

			public WhereParameter ProdID
		    {
				get
		        {
					if(_ProdID_W == null)
	        	    {
						_ProdID_W = TearOff.ProdID;
					}
					return _ProdID_W;
				}
			}

			public WhereParameter SaledPrice
		    {
				get
		        {
					if(_SaledPrice_W == null)
	        	    {
						_SaledPrice_W = TearOff.SaledPrice;
					}
					return _SaledPrice_W;
				}
			}

			public WhereParameter SaleDate
		    {
				get
		        {
					if(_SaleDate_W == null)
	        	    {
						_SaleDate_W = TearOff.SaleDate;
					}
					return _SaleDate_W;
				}
			}

			public WhereParameter SaleTime
		    {
				get
		        {
					if(_SaleTime_W == null)
	        	    {
						_SaleTime_W = TearOff.SaleTime;
					}
					return _SaleTime_W;
				}
			}

			public WhereParameter SaleQuantity
		    {
				get
		        {
					if(_SaleQuantity_W == null)
	        	    {
						_SaleQuantity_W = TearOff.SaleQuantity;
					}
					return _SaleQuantity_W;
				}
			}

			private WhereParameter _SaleID_W = null;
			private WhereParameter _ProdID_W = null;
			private WhereParameter _SaledPrice_W = null;
			private WhereParameter _SaleDate_W = null;
			private WhereParameter _SaleTime_W = null;
			private WhereParameter _SaleQuantity_W = null;

			public void WhereClauseReset()
			{
				_SaleID_W = null;
				_ProdID_W = null;
				_SaledPrice_W = null;
				_SaleDate_W = null;
				_SaleTime_W = null;
				_SaleQuantity_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
	
		#region Aggregate Clause
		public class AggregateClause
		{
			public AggregateClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffAggregateParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffAggregateParameter(this);
					}

					return _tearOff;
				}
			}

			#region AggregateParameter TearOff's
			public class TearOffAggregateParameter
			{
				public TearOffAggregateParameter(AggregateClause clause)
				{
					this._clause = clause;
				}
				
				
				public AggregateParameter SaleID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SaleID, Parameters.SaleID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter ProdID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.ProdID, Parameters.ProdID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SaledPrice
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SaledPrice, Parameters.SaledPrice);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SaleDate
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SaleDate, Parameters.SaleDate);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SaleTime
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SaleTime, Parameters.SaleTime);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SaleQuantity
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SaleQuantity, Parameters.SaleQuantity);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter SaleID
		    {
				get
		        {
					if(_SaleID_W == null)
	        	    {
						_SaleID_W = TearOff.SaleID;
					}
					return _SaleID_W;
				}
			}

			public AggregateParameter ProdID
		    {
				get
		        {
					if(_ProdID_W == null)
	        	    {
						_ProdID_W = TearOff.ProdID;
					}
					return _ProdID_W;
				}
			}

			public AggregateParameter SaledPrice
		    {
				get
		        {
					if(_SaledPrice_W == null)
	        	    {
						_SaledPrice_W = TearOff.SaledPrice;
					}
					return _SaledPrice_W;
				}
			}

			public AggregateParameter SaleDate
		    {
				get
		        {
					if(_SaleDate_W == null)
	        	    {
						_SaleDate_W = TearOff.SaleDate;
					}
					return _SaleDate_W;
				}
			}

			public AggregateParameter SaleTime
		    {
				get
		        {
					if(_SaleTime_W == null)
	        	    {
						_SaleTime_W = TearOff.SaleTime;
					}
					return _SaleTime_W;
				}
			}

			public AggregateParameter SaleQuantity
		    {
				get
		        {
					if(_SaleQuantity_W == null)
	        	    {
						_SaleQuantity_W = TearOff.SaleQuantity;
					}
					return _SaleQuantity_W;
				}
			}

			private AggregateParameter _SaleID_W = null;
			private AggregateParameter _ProdID_W = null;
			private AggregateParameter _SaledPrice_W = null;
			private AggregateParameter _SaleDate_W = null;
			private AggregateParameter _SaleTime_W = null;
			private AggregateParameter _SaleQuantity_W = null;

			public void AggregateClauseReset()
			{
				_SaleID_W = null;
				_ProdID_W = null;
				_SaledPrice_W = null;
				_SaleDate_W = null;
				_SaleTime_W = null;
				_SaleQuantity_W = null;

				this._entity.Query.FlushAggregateParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffAggregateParameter _tearOff;
			
		}
	
		public AggregateClause Aggregate
		{
			get
			{
				if(_aggregateClause == null)
				{
					_aggregateClause = new AggregateClause(this);
				}
		
				return _aggregateClause;
			}
		}
		
		private AggregateClause _aggregateClause = null;	
		#endregion
	
		protected override IDbCommand GetInsertCommand() 
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SalesInsert]";
	
			CreateParameters(cmd);
			
			SqlParameter p;
			p = cmd.Parameters[Parameters.SaleID.ParameterName];
			p.Direction = ParameterDirection.Output;
    
			return cmd;
		}
	
		protected override IDbCommand GetUpdateCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SalesUpdate]";
	
			CreateParameters(cmd);
			      
			return cmd;
		}
	
		protected override IDbCommand GetDeleteCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SalesDelete]";
	
			SqlParameter p;
			p = cmd.Parameters.Add(Parameters.SaleID);
			p.SourceColumn = ColumnNames.SaleID;
			p.SourceVersion = DataRowVersion.Current;

  
			return cmd;
		}
		
		private IDbCommand CreateParameters(SqlCommand cmd)
		{
			SqlParameter p;
		
			p = cmd.Parameters.Add(Parameters.SaleID);
			p.SourceColumn = ColumnNames.SaleID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.ProdID);
			p.SourceColumn = ColumnNames.ProdID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SaledPrice);
			p.SourceColumn = ColumnNames.SaledPrice;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SaleDate);
			p.SourceColumn = ColumnNames.SaleDate;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SaleTime);
			p.SourceColumn = ColumnNames.SaleTime;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SaleQuantity);
			p.SourceColumn = ColumnNames.SaleQuantity;
			p.SourceVersion = DataRowVersion.Current;


			return cmd;
		}
	}
}
